home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xprof
/
table.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
21KB
|
456 lines
/*==================================================================
* File : table.c
* Package: Xprof
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
*==================================================================*/
#include <stdio.h>
#include "common.h"
#include "profile.h"
extern long OpenFont(); /* Opcode 45 */
extern long CloseFont(); /* Opcode 46 */
extern long CreateGC(); /* Opcode 55 */
extern long ChangeGC(); /* Opcode 56 */
extern long CopyGC(); /* Opcode 57 */
extern long FreeGC(); /* Opcode 60 */
extern long ClearArea(); /* Opcode 61 */
extern long CopyArea(); /* Opcode 62 */
extern long CopyPlane(); /* Opcode 63 */
extern long PolyPoint(); /* Opcode 64 */
extern long PolyLine(); /* Opcode 65 */
extern long PolySegment(); /* Opcode 66 */
extern long PolyRectangle(); /* Opcode 67 */
extern long PolyFillRectangle();/* Opcode 70 */
extern long PutImage(); /* Opcode 72 */
extern long GetImage(); /* Opcode 73 */
extern long PolyText8(); /* Opcode 74 */
extern long PolyText16(); /* Opcode 75 */
extern long ImageText8(); /* Opcode 76 */
extern long ImageText16(); /* Opcode 77 */
extern MsgStats RequestStats[];
extern MsgStats ReplyStats[];
extern MsgStats EventStats[];
extern MsgStats ErrorStats[];
long default_request();
long default_reply();
long default_event();
long default_error();
/*
* The following arrays contain the symbolic names of the X messages and the
* actions to be taken to process them.
*/
MsgType RequestType[]={
0, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
1, "CreateWindow", WIN, default_request, TERSE, GRAIN1,
2, "ChangeWindowAttributes", WIN, default_request, TERSE, GRAIN1,
3, "GetWindowAttributes", WIN, default_request, TERSE, GRAIN1,
4, "DestroyWindow", WIN, default_request, TERSE, GRAIN1,
5, "DestroySubwindows", WIN, default_request, TERSE, GRAIN1,
6, "ChangeSaveSet", WIN, default_request, TERSE, GRAIN1,
7, "ReparentWindow", WIN, default_request, TERSE, GRAIN1,
8, "MapWindow", WIN, default_request, TERSE, GRAIN1,
9, "MapSubwindows", WIN, default_request, TERSE, GRAIN1,
10, "UnmapWindow", WIN, default_request, TERSE, GRAIN1,
11, "UnmapSubwindows", WIN, default_request, TERSE, GRAIN1,
12, "ConfigureWindow", WIN, default_request, TERSE, GRAIN1,
13, "CirculateWindow", WIN, default_request, TERSE, GRAIN1,
14, "GetGeometry", WIN, default_request, TERSE, GRAIN1,
15, "QueryTree", WIN, default_request, TERSE, GRAIN1,
16, "InternAtom", WIN, default_request, TERSE, GRAIN1,
17, "GetAtomName", WIN, default_request, TERSE, GRAIN1,
18, "ChangeProperty", WIN, default_request, TERSE, GRAIN1,
19, "DeleteProperty", WIN, default_request, TERSE, GRAIN1,
20, "GetProperty", WIN, default_request, TERSE, GRAIN1,
21, "ListProperties", WIN, default_request, TERSE, GRAIN1,
22, "SetSelectionOwner", WIN, default_request, TERSE, GRAIN1,
23, "GetSelectionOwner", WIN, default_request, TERSE, GRAIN1,
24, "ConvertSelection", WIN, default_request, TERSE, GRAIN1,
25, "SendEvent", WIN, default_request, TERSE, GRAIN1,
26, "GrabPointer", WIN, default_request, TERSE, GRAIN1,
27, "UngrabPointer", WIN, default_request, TERSE, GRAIN1,
28, "GrabButton", WIN, default_request, TERSE, GRAIN1,
29, "UngrabButton", WIN, default_request, TERSE, GRAIN1,
30, "ChangeActivePointerGrab",WIN, default_request, TERSE, GRAIN1,
31, "GrabKeyboard", WIN, default_request, TERSE, GRAIN1,
32, "UngrabKeyboard", WIN, default_request, TERSE, GRAIN1,
33, "GrabKey", WIN, default_request, TERSE, GRAIN1,
34, "UngrabKey", WIN, default_request, TERSE, GRAIN1,
35, "AllowEvents", WIN, default_request, TERSE, GRAIN1,
36, "GrabServer", WIN, default_request, TERSE, GRAIN1,
37, "UngrabServer", WIN, default_request, TERSE, GRAIN1,
38, "QueryPointer", WIN, default_request, TERSE, GRAIN1,
39, "GetMotionEvents", WIN, default_request, TERSE, GRAIN1,
40, "TranslateCoordinates", WIN, default_request, TERSE, GRAIN1,
41, "WarpPointer", WIN, default_request, TERSE, GRAIN1,
42, "SetInputFocus", WIN, default_request, TERSE, GRAIN1,
43, "GetInputFocus", WIN, default_request, TERSE, GRAIN1,
44, "QueryKeymap", WIN, default_request, TERSE, GRAIN1,
45, "OpenFont", WIN, OpenFont, TERSE, GRAIN1,
46, "CloseFont", WIN, CloseFont, TERSE, GRAIN1,
47, "QueryFont", WIN, default_request, TERSE, GRAIN1,
48, "QueryTextExtents", WIN, default_request, TERSE, GRAIN1,
49, "ListFonts", WIN, default_request, TERSE, GRAIN1,
50, "ListFontsWithInfo", WIN, default_request, TERSE, GRAIN1,
51, "SetFontPath", WIN, default_request, TERSE, GRAIN1,
52, "GetFontPath", WIN, default_request, TERSE, GRAIN1,
53, "CreatePixmap", WIN, default_request, TERSE, GRAIN1,
54, "FreePixmap", WIN, default_request, TERSE, GRAIN1,
55, "CreateGC", WIN, CreateGC, TERSE, GRAIN1,
56, "ChangeGC", WIN, ChangeGC, TERSE, GRAIN1,
57, "CopyGC", WIN, CopyGC, TERSE, GRAIN1,
58, "SetDashes", WIN, default_request, TERSE, GRAIN1,
59, "SetClipRectangles", WIN, default_request, TERSE, GRAIN1,
60, "FreeGC", WIN, FreeGC, TERSE, GRAIN1,
61, "ClearArea", WIN, ClearArea, DETAILED, GRAIN16,
62, "CopyArea", WIN, CopyArea, DETAILED, GRAIN16,
63, "CopyPlane", WIN, CopyPlane, DETAILED, GRAIN16,
64, "PolyPoint", GFX, PolyPoint, DETAILED, GRAIN1,
65, "PolyLine", GFX, PolyLine, DETAILED, GRAIN1,
66, "PolySegment", GFX, PolySegment, DETAILED, GRAIN1,
67, "PolyRectangle", GFX, PolyRectangle, DETAILED, GRAIN1,
68, "PolyArc", GFX, default_request, TERSE, GRAIN1,
69, "FillPoly", GFX, default_request, TERSE, GRAIN1,
70, "PolyFillRectangle", GFX, PolyFillRectangle, DETAILED, GRAIN256,
71, "PolyFillArc", GFX, default_request, TERSE, GRAIN1,
72, "PutImage", WIN, PutImage, DETAILED, GRAIN16,
73, "GetImage", WIN, GetImage, DETAILED, GRAIN16,
74, "PolyText8", TXT, PolyText8, DETAILED, GRAIN1,
75, "PolyText16", TXT, PolyText16, DETAILED, GRAIN1,
76, "ImageText8", TXT, ImageText8, DETAILED, GRAIN1,
77, "ImageText16", TXT, ImageText16, DETAILED, GRAIN1,
78, "CreateColormap", WIN, default_request, TERSE, GRAIN1,
79, "FreeColormap", WIN, default_request, TERSE, GRAIN1,
80, "CopyColormapAndFree", WIN, default_request, TERSE, GRAIN1,
81, "InstallColormap", WIN, default_request, TERSE, GRAIN1,
82, "UninstallColormap", WIN, default_request, TERSE, GRAIN1,
83, "ListInstalledColormaps", WIN, default_request, TERSE, GRAIN1,
84, "AllocColor", WIN, default_request, TERSE, GRAIN1,
85, "AllocNamedColor", WIN, default_request, TERSE, GRAIN1,
86, "AllocColorCells", WIN, default_request, TERSE, GRAIN1,
87, "AllocColorPlanes", WIN, default_request, TERSE, GRAIN1,
88, "FreeColors", WIN, default_request, TERSE, GRAIN1,
89, "StoreColors", WIN, default_request, TERSE, GRAIN1,
90, "StoreNamedColor", WIN, default_request, TERSE, GRAIN1,
91, "QueryColors", WIN, default_request, TERSE, GRAIN1,
92, "LookupColor", WIN, default_request, TERSE, GRAIN1,
93, "CreateCursor", WIN, default_request, TERSE, GRAIN1,
94, "CreateGlyphCursor", WIN, default_request, TERSE, GRAIN1,
95, "FreeCursor", WIN, default_request, TERSE, GRAIN1,
96, "RecolorCursor", WIN, default_request, TERSE, GRAIN1,
97, "QueryBestSize", WIN, default_request, TERSE, GRAIN1,
98, "QueryExtension", WIN, default_request, TERSE, GRAIN1,
99, "ListExtensions", WIN, default_request, TERSE, GRAIN1,
100, "ChangeKeyboardMapping", WIN, default_request, TERSE, GRAIN1,
101, "GetKeyboardMapping", WIN, default_request, TERSE, GRAIN1,
102, "ChangeKeyboardControl", WIN, default_request, TERSE, GRAIN1,
103, "GetKeyboardControl", WIN, default_request, TERSE, GRAIN1,
104, "Bell", WIN, default_request, TERSE, GRAIN1,
105, "ChangePointerControl", WIN, default_request, TERSE, GRAIN1,
106, "GetPointerControl", WIN, default_request, TERSE, GRAIN1,
107, "SetScreenSaver", WIN, default_request, TERSE, GRAIN1,
108, "GetScreenSaver", WIN, default_request, TERSE, GRAIN1,
109, "ChangeHosts", WIN, default_request, TERSE, GRAIN1,
110, "ListHosts", WIN, default_request, TERSE, GRAIN1,
111, "SetAccessControl", WIN, default_request, TERSE, GRAIN1,
112, "SetCloseDownMode", WIN, default_request, TERSE, GRAIN1,
113, "KillClient", WIN, default_request, TERSE, GRAIN1,
114, "RotateProperties", WIN, default_request, TERSE, GRAIN1,
115, "ForceScreenSaver", WIN, default_request, TERSE, GRAIN1,
116, "SetPointerMapping", WIN, default_request, TERSE, GRAIN1,
117, "GetPointerMapping", WIN, default_request, TERSE, GRAIN1,
118, "SetModifierMapping", WIN, default_request, TERSE, GRAIN1,
119, "GetModifierMapping", WIN, default_request, TERSE, GRAIN1,
120, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
121, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
122, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
123, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
124, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
125, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
126, "Undefined Request", WIN, default_request, TERSE, GRAIN1,
127, "NoOperation", WIN, default_request, TERSE, GRAIN1,
};
MsgType ReplyType[]={
0, "Undefined", WIN, default_reply, TERSE, GRAIN1,
3, "GetWindowAttributes", WIN, default_reply, TERSE, GRAIN1,
14, "GetGeometry", WIN, default_reply, TERSE, GRAIN1,
15, "QueryTree", WIN, default_reply, TERSE, GRAIN1,
16, "InternAtom", WIN, default_reply, TERSE, GRAIN1,
17, "GetAtomName", WIN, default_reply, TERSE, GRAIN1,
20, "GetProperty", WIN, default_reply, TERSE, GRAIN1,
21, "ListProperties", WIN, default_reply, TERSE, GRAIN1,
23, "GetSelectionOwner", WIN, default_reply, TERSE, GRAIN1,
26, "GrabPointer", WIN, default_reply, TERSE, GRAIN1,
31, "GrabKeyboard", WIN, default_reply, TERSE, GRAIN1,
38, "QueryPointer", WIN, default_reply, TERSE, GRAIN1,
39, "GetMotionEvents", WIN, default_reply, TERSE, GRAIN1,
40, "TranslateCoordinates", WIN, default_reply, TERSE, GRAIN1,
43, "GetInputFocus", WIN, default_reply, TERSE, GRAIN1,
44, "QueryKeymap", WIN, default_reply, TERSE, GRAIN1,
47, "QueryFont", WIN, default_reply, TERSE, GRAIN1,
48, "QueryTextExtents", WIN, default_reply, TERSE, GRAIN1,
49, "ListFonts", WIN, default_reply, TERSE, GRAIN1,
50, "ListFontsWithInfo", WIN, default_reply, TERSE, GRAIN1,
52, "GetFontPath", WIN, default_reply, TERSE, GRAIN1,
73, "GetImage", WIN, default_reply, TERSE, GRAIN1,
83, "ListInstalledColormaps", WIN, default_reply, TERSE, GRAIN1,
84, "AllocColor", WIN, default_reply, TERSE, GRAIN1,
85, "AllocNamedColor", WIN, default_reply, TERSE, GRAIN1,
86, "AllocColorCells", WIN, default_reply, TERSE, GRAIN1,
87, "AllocColorPlanes", WIN, default_reply, TERSE, GRAIN1,
91, "QueryColors", WIN, default_reply, TERSE, GRAIN1,
92, "LookupColor", WIN, default_reply, TERSE, GRAIN1,
97, "QueryBestSize", WIN, default_reply, TERSE, GRAIN1,
98, "QueryExtension", WIN, default_reply, TERSE, GRAIN1,
99, "ListExtensions", WIN, default_reply, TERSE, GRAIN1,
101, "GetKeyboardMapping", WIN, default_reply, TERSE, GRAIN1,
103, "GetKeyboardControl", WIN, default_reply, TERSE, GRAIN1,
106, "GetPointerControl", WIN, default_reply, TERSE, GRAIN1,
108, "GetScreenSaver", WIN, default_reply, TERSE, GRAIN1,
110, "ListHosts", WIN, default_reply, TERSE, GRAIN1,
116, "SetPointerMapping", WIN, default_reply, TERSE, GRAIN1,
117, "GetPointerMapping", WIN, default_reply, TERSE, GRAIN1,
118, "SetModifierMapping", WIN, default_reply, TERSE, GRAIN1,
119, "GetModifierMapping", WIN, default_reply, TERSE, GRAIN1,
};
MsgType EventType[]={
0, "Undefined", WIN, default_event, TERSE, GRAIN1,
1, "Undefined", WIN, default_event, TERSE, GRAIN1,
2, "KeyPress", WIN, default_event, TERSE, GRAIN1,
3, "KeyRelease", WIN, default_event, TERSE, GRAIN1,
4, "ButtonPress", WIN, default_event, TERSE, GRAIN1,
5, "ButtonRelease", WIN, default_event, TERSE, GRAIN1,
6, "MotionNotify", WIN, default_event, TERSE, GRAIN1,
7, "EnterNotify", WIN, default_event, TERSE, GRAIN1,
8, "LeaveNotify", WIN, default_event, TERSE, GRAIN1,
9, "FocusIn", WIN, default_event, TERSE, GRAIN1,
10, "FocusOut", WIN, default_event, TERSE, GRAIN1,
11, "KeymapNotify", WIN, default_event, TERSE, GRAIN1,
12, "Expose", WIN, default_event, TERSE, GRAIN1,
13, "GraphicsExposure", WIN, default_event, TERSE, GRAIN1,
14, "NoExposure", WIN, default_event, TERSE, GRAIN1,
15, "VisibilityNotify", WIN, default_event, TERSE, GRAIN1,
16, "CreateNotify", WIN, default_event, TERSE, GRAIN1,
17, "DestroyNotify", WIN, default_event, TERSE, GRAIN1,
18, "UnmapNotify", WIN, default_event, TERSE, GRAIN1,
19, "MapNotify", WIN, default_event, TERSE, GRAIN1,
20, "MapRequest", WIN, default_event, TERSE, GRAIN1,
21, "ReparentNotify", WIN, default_event, TERSE, GRAIN1,
22, "ConfigureNotify", WIN, default_event, TERSE, GRAIN1,
23, "ConfigureRequest", WIN, default_event, TERSE, GRAIN1,
24, "GravityNotify", WIN, default_event, TERSE, GRAIN1,
25, "ResizeRequest", WIN, default_event, TERSE, GRAIN1,
26, "CirculateNotify", WIN, default_event, TERSE, GRAIN1,
27, "CirculateRequest", WIN, default_event, TERSE, GRAIN1,
28, "PropertyNotify", WIN, default_event, TERSE, GRAIN1,
29, "SelectionClear", WIN, default_event, TERSE, GRAIN1,
30, "SelectionRequest", WIN, default_event, TERSE, GRAIN1,
31, "SelectionNotify", WIN, default_event, TERSE, GRAIN1,
32, "ColormapNotify", WIN, default_event, TERSE, GRAIN1,
33, "ClientMessage", WIN, default_event, TERSE, GRAIN1,
34, "MappingNotify", WIN, default_event, TERSE, GRAIN1,
};
MsgType ErrorType[]={
0, "Success", WIN, default_error, TERSE, GRAIN1,
1, "Request", WIN, default_error, TERSE, GRAIN1,
2, "Value", WIN, default_error, TERSE, GRAIN1,
3, "Window", WIN, default_error, TERSE, GRAIN1,
4, "Pixmap", WIN, default_error, TERSE, GRAIN1,
5, "Atom", WIN, default_error, TERSE, GRAIN1,
6, "Cursor", WIN, default_error, TERSE, GRAIN1,
7, "Font", WIN, default_error, TERSE, GRAIN1,
8, "Match", WIN, default_error, TERSE, GRAIN1,
9, "Drawable", WIN, default_error, TERSE, GRAIN1,
10, "Access", WIN, default_error, TERSE, GRAIN1,
11, "Alloc", WIN, default_error, TERSE, GRAIN1,
12, "Colormap", WIN, default_error, TERSE, GRAIN1,
13, "GContext", WIN, default_error, TERSE, GRAIN1,
14, "IDChoice", WIN, default_error, TERSE, GRAIN1,
15, "Name", WIN, default_error, TERSE, GRAIN1,
16, "Length", WIN, default_error, TERSE, GRAIN1,
17, "Implementation", WIN, default_error, TERSE, GRAIN1,
};
long default_request(fp, num, current_time)
FILE *fp; /* Data stream */
int num; /* Request Number */
long current_time; /* Current time in ms */
{
int length;
long bytes;
char sbuf[132], sbuf1[132];
char in_string[MAXSTRINGSIZE];
char *ptr;
Xattributes attributes;
if (RequestStats[num].invoked == FALSE)
InitMsgStats(&RequestStats[num],current_time, RequestType[num].detailed,
RequestType[num].size_grain);
/* InitMsgStats(&RequestStats[num],current_time, DETAILED,
RequestType[num].size_grain); */
/* Extract the number of bytes in the message and return */
while (1) {
if (fgets(in_string, MAXSTRINGSIZE, fp) == NULL)
return(0);
_LINE_NUM++;
ptr = in_string;
while (isspace(*ptr)) ptr++; /* Remove leading white space */
if (t_search(ptr, "request length" ) != NULL) {
sscanf(ptr,"%s %s %x", sbuf, sbuf1, &length);
goto end;
}
}
end:
bytes = length * 4;
attributes.bytes = bytes;
attributes.size = (float) bytes;
update_profile(num, &attributes);
/* Fill the data Structure for this message */
FillMsgStats(&RequestStats[num], current_time, bytes, bytes);
return (bytes);
}
long default_reply(fp, index, current_time)
FILE *fp; /* Data stream */
int index; /* reply index */
long current_time; /* Current time in ms */
{
int length;
long bytes;
char sbuf[132], sbuf1[132];
char in_string[MAXSTRINGSIZE];
char *ptr;
if (ReplyStats[index].invoked == FALSE)
InitMsgStats(&ReplyStats[index],current_time,ReplyType[index].detailed,
ReplyType[index].size_grain);
/* Extract the number of bytes in the message and return */
while (1) {
if (fgets(in_string, MAXSTRINGSIZE, fp) == NULL)
return(0);
_LINE_NUM++;
ptr = in_string;
while (isspace(*ptr)) ptr++; /* Remove leading white space */
if (t_search(ptr, "reply length" ) != NULL) {
sscanf(ptr,"%s %s %x", sbuf, sbuf1, &length);
goto end;
}
}
end:
bytes = (length * 4) + 32;
/* Fill the data Structure for this message */
FillMsgStats(&ReplyStats[index], current_time, bytes, bytes);
return (bytes);
}
long default_event(fp, index, current_time)
FILE *fp; /* Data stream */
int index; /* event index */
long current_time; /* Current time in ms */
{
long bytes=32; /* All events are 32 bytes in size */
if (EventStats[index].invoked == FALSE)
InitMsgStats(&EventStats[index],current_time,EventType[index].detailed,
EventType[index].size_grain);
/* Fill the data Structure for this message */
FillMsgStats(&EventStats[index], current_time, bytes, bytes);
return (bytes);
}
long default_error(fp, index, current_time)
FILE *fp; /* Data stream */
int index; /* error index */
long current_time; /* Current time in ms */
{
long bytes=32; /* All errors are 32 bytes in size */
if (ErrorStats[index].invoked == FALSE)
InitMsgStats(&ErrorStats[index],current_time,ErrorType[index].detailed,
ErrorType[index].size_grain);
/* Fill the data Structure for this message */
FillMsgStats(&ErrorStats[index], current_time, bytes, bytes);
return (bytes);
}
/* Search the index value for the request string */
int lookup_request(name)
char *name;
{
int index;
for (index=0; index < MAXREQUESTS; index++)
if (!strcmp(name, RequestType[index].name))
return(index);
fprintf(stderr,"Error: Undefined Request: %s Line: %d\n",
name, _LINE_NUM);
fflush(stderr);
return(0); /* Return undefined request */
}
/* Search the index value for the reply string */
int lookup_reply(name)
char *name;
{
int index;
for (index=0; index < MAXREPLIES; index++)
if (!strcmp(name, ReplyType[index].name))
return(index);
fprintf(stderr,"Error: Undefined Reply: %s. Line %d\n",
name, _LINE_NUM);
fflush(stderr);
return(0); /* Return undefined reply */
}
/* Search the index value for the event string */
int lookup_event(name)
char *name;
{
int index;
for (index=0; index < MAXEVENTS; index++)
if (!strcmp(name, EventType[index].name))
return(index);
fprintf(stderr,"Error: Undefined Event: %s. Line %d\n",
name, _LINE_NUM);
fflush(stderr);
return(0); /* Return undefined event */
}
/* Search the index value for the error string */
int lookup_error(name)
char *name;
{
int index;
for (index=0; index < MAXERRORS; index++)
if (!strcmp(name, ErrorType[index].name))
return(index);
fprintf(stderr,"Error: Undefined Error: %s. Line %d\n",
name, _LINE_NUM);
fflush(stderr);
return(0); /* Retrun undefined error */
}